// main.cpp
#include "mcts.h"
#include <iostream>

int main() {
    // Initialize a new game with a 19x19 board
    GameState game = GameState::new_game(19); // Assuming a static method new_game exists

    // Initialize the MCTS Agent with desired parameters
    int num_rounds = 1000;       // Number of MCTS iterations
    double temperature = 1.4;    // Exploration parameter
    MCTSAgent agent(num_rounds, temperature);

    // Example game loop: players take turns until the game is over
    while (!game.is_over()) {
        // Agent selects a move
        Move move = agent.select_move(game);

        // Apply the move to the game state
        game = game.apply_move(move);

        // For demonstration, print the move
        if (move.is_play) {
            std::cout << "Player " << (game.next_player == Player::Black ? "White" : "Black")
                      << " plays at (" << move.point.row << ", " << move.point.col << ")\n";
        } else if (move.is_pass) {
            std::cout << "Player " << (game.next_player == Player::Black ? "White" : "Black")
                      << " passes.\n";
        } else if (move.is_resign) {
            std::cout << "Player " << (game.next_player == Player::Black ? "White" : "Black")
                      << " resigns.\n";
        }
    }

    // Determine and announce the winner
    Player winner = game.get_winner();
    if (winner == Player::Black) {
        std::cout << "Black wins!\n";
    } else {
        std::cout << "White wins!\n";
    }

    return 0;
}
